package com.wyw.springcloud.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 文件介绍
 *
 * @Author： Mr Wu （yewen.wu.china.gmail.com）
 * @Date: 2020/9/11 17:09
 */
@RestController
@Slf4j
public class TestController {

    private static String port;

    @Value("${server.port}")
    public void setPort(String port) {
        TestController.port = port;
    }

    @GetMapping("/sayHi")
    public String sayHi(){
        return "This is " + port;
    }

    @PostMapping("/postStudent")
    public Student PostStudent(@RequestBody Student student){
        log.info("学生{}", student);
        student.setPort(port);
        return student;
    }
}
